<template>
  <!-- 举报的招聘详情 -->
      <div class="report-detail2">
        <el-page-header @back="goBack" content="详情页面">
        </el-page-header>
        <!--  职位描述-->
        <div id="describe">
          <div id="detail-child">
            <div>
              <h4>职位描述</h4>
              <div class="describe-list">
                <p v-for="(item,index) in recruitment.duties">{{index+1}}、{{item.dutyExplain}}</p>
              </div>
            </div>
            <div>
              <h4>技能要求</h4>
              <div class="describe-list">
                <p v-for="(item,index) in recruitment.skills">{{index+1}}、{{item.skillExplain}}</p>
              </div>
            </div>
           <div>
             <h4>福利</h4>
             <div class="welfare">
               <el-tag style="margin: 2px" v-for="item in treatment" type="success">{{item}}</el-tag>
             </div>
           </div>

          </div>
        </div>
        <p>举报人:{{userName}}</p>
        <p>举报说明:{{report.content}}</p>
        <div v-if="report.state!=0" style="display: flex">
          <h3>审核结果:</h3>
          <h3 style="color: orange" v-if="report.state==1">举报成功</h3><h3 v-else style="color: orange">举报失败</h3>
        </div>
        <div v-else>
          <el-button @click="success" type="success">通过举报</el-button>
          <el-button @click="fail" type="danger">驳回举报</el-button>
        </div>
      </div>
</template>

<script>
import {failReport, getArchives, getDeal, passReport} from "@/network/admin";

export default {
  name: "recReDetails",
  data(){
    return{
      id:0,
      recruitment:{},
      report:{},
      userName:''
    }
  },
  created() {
    let id=this.$route.query.id
    this.id=id
    getDeal(id).then(res=>{
      console.log(res)
      this.recruitment=res.data.extend.recruitment
      this.report=res.data.extend.report
      this.getUserName(this.report.type,this.report.uid)
    })
  },
  computed:{
    treatment(){
      return this.recruitment.treatment.split(',')
    }
  },
  methods:{
    getUserName(type,uid){
      getArchives(type,uid).then(res=>{
        let data=res.data.extend.object
        this.userName=data.studentName||data.companyName||data.universityName
      })
    },
    fail(){
      failReport(this.id).then(res=>{
        this.$message.success(res.data.msg)
        this.goBack()
      })
    },
    success(){
      passReport(this.id).then(res=>{
        this.$message.success(res.data.msg)
        this.goBack()
      })
    },
    goBack(){
      this.$router.go(-1)
    }
  }
}
</script>

<style lang="stylus" scoped>
#describe
  margin-top 20px
  border 2px solid orange
  width 100%
  box-sizing border-box
  display flex
  justify-content space-between
  padding 10px
  & h4
    text-decoration underline orange
    line-height 30px
.describe-list p
  font-size 15px
  color rgb(97,104,124)
  line-height 38px
.industrial-list p
  line-height 30px
  font-size 15px
#detail-child
  width 100%
  display flex
  &>div
    width 30%
</style>
